package com.fish.anne.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="system_action" )
public class SystemAction extends BaseObject implements Serializable {
    private Long actionId;
    private String actionDescription;
    private String actionName;
    private String actionUrl;
    private boolean leafOn;
    private Long parentId;

    
    
    private List<SystemAction> subActions ;

    
    @Transient
    public List<SystemAction> getSubActions() {
		return subActions;
	}

	public void setSubActions(List<SystemAction> subActions) {
		this.subActions = subActions;
	}
	
    @Id   @GeneratedValue(strategy = GenerationType.AUTO)    
    public Long getActionId() {
        return this.actionId;
    }
    
    public void setActionId(Long actionId) {
        this.actionId = actionId;
    }
    
    @Column(name="action_description", nullable=false)
    public String getActionDescription() {
        return this.actionDescription;
    }
    
    public void setActionDescription(String actionDescription) {
        this.actionDescription = actionDescription;
    }
    
    @Column(name="action_name", nullable=false)
    public String getActionName() {
        return this.actionName;
    }
    
    public void setActionName(String actionName) {
        this.actionName = actionName;
    }
    
    @Column(name="action_url", nullable=false)
    public String getActionUrl() {
        return this.actionUrl;
    }
    
    public void setActionUrl(String actionUrl) {
        this.actionUrl = actionUrl;
    }
    
    @Column(name="leaf_on", nullable=false)
    public boolean isLeafOn() {
        return this.leafOn;
    }
    
    public void setLeafOn(boolean leafOn) {
        this.leafOn = leafOn;
    }
    
    @Column(name="parent_id", nullable=false)
    public Long getParentId() {
        return this.parentId;
    }
    
    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SystemAction pojo = (SystemAction) o;

        if (actionDescription != null ? !actionDescription.equals(pojo.actionDescription) : pojo.actionDescription != null) return false;
        if (actionName != null ? !actionName.equals(pojo.actionName) : pojo.actionName != null) return false;
        if (actionUrl != null ? !actionUrl.equals(pojo.actionUrl) : pojo.actionUrl != null) return false;
        if (leafOn != pojo.leafOn) return false;
        if (parentId != null ? !parentId.equals(pojo.parentId) : pojo.parentId != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (actionDescription != null ? actionDescription.hashCode() : 0);
        result = 31 * result + (actionName != null ? actionName.hashCode() : 0);
        result = 31 * result + (actionUrl != null ? actionUrl.hashCode() : 0);
        result = 31 * result + (leafOn ? 1 : 0);
        result = 31 * result + (parentId != null ? parentId.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("actionId").append("='").append(getActionId()).append("', ");
        sb.append("actionDescription").append("='").append(getActionDescription()).append("', ");
        sb.append("actionName").append("='").append(getActionName()).append("', ");
        sb.append("actionUrl").append("='").append(getActionUrl()).append("', ");
        sb.append("leafOn").append("='").append(isLeafOn()).append("', ");
        sb.append("parentId").append("='").append(getParentId()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
